CC=g++
CFLAGS=-c -Wall
LIBS=-lantlr3c
LDFLAGS=

PARSER=PseudoGrep.g
SOURCES=PseudoGrep.cpp AFND.cpp AFD.cpp
EXECUTABLE=pseudogrep

TMPSRC=$(PARSER:.g=Parser.c) $(PARSER:.g=Lexer.c)
TMPHEADERS=$(TMPSRC:.c=.h) $(PARSER:.g=.tokens)
SRC=$(TMPSRC) $(SOURCES)
_OBJECTS=$(SRC:.cpp=.o)
OBJECTS=$(_OBJECTS:.c=.o)

all: $(EXECUTABLE)

clean:
	rm -f $(OBJECTS) $(TMPSRC) $(TMPHEADERS) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS) 
	$(CC) $(LDFLAGS) $(LIBS) $(OBJECTS) -o $@

parser:
	antlr3 $(PARSER)

.cpp.o:
	$(CC) $(CFLAGS) $< -o $@

.c.o:
	$(CC) $(CFLAGS) $< -o $@
